home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / ABUSESRC.ZIP / AbuseSrc / macabuse / src / extend.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-05-20  |  2.8 KB  |  140 lines

  1. /*
  2.  
  3.  
  4.  
  5.   Simple object             (power ups, non-moving objects)
  6.     long x,y;
  7.     schar direction;
  8.     ushort otype,state
  9.     ushort current_frame;
  10.     extension *
  11.  
  12.  
  13.   Moving object             (simple lisp controlled characters)
  14.      uchar flags;
  15.      long xvel,yvel,xacel,yacel;
  16.      uchar fx,fy,fxvel,fyvel,fxacel,fyacel,aitype;
  17.      ushort aistate,aistate_time;
  18.      unsigned short hp,mp,
  19.      extension *
  20.  
  21.  
  22.   Complex objects          (can controll lights, other characters, and have a neural net ai)
  23.     uchar tobjs,tlights;
  24.     object_list *                       
  25.     light_list *
  26.     nnet_info *
  27.     schar fade_dir, frame_dir;        
  28.     unsigned char fade_count,fade_max;
  29.     morph_char *morph_status;
  30.  
  31.  
  32. */
  33. #include "extend.hpp"
  34. #include "view.hpp"
  35. #include "objects.hpp"
  36. #include "lisp.hpp"
  37.  
  38.  
  39. void simple_object::add_light(light_source *ls)
  40.   if (!ls) return ;
  41.   ls->known=1;
  42.   for (int i=0;i<tlights;i++) if (lights[i]==ls) return;
  43.   tlights++; 
  44.   lights=(light_source **)jrealloc(lights,sizeof(light_source *)*tlights,"Light list");
  45.   lights[tlights-1]=ls;
  46. }
  47.  
  48. void simple_object::add_object(game_object *o)
  49. {
  50.   if (!o) return ;
  51.   for (int i=0;i<tobjs;i++) if (objs[i]==o) return;
  52.   o->set_flags(o->flags()|KNOWN_FLAG);
  53.   tobjs++;
  54.   objs=(game_object **)jrealloc(objs,sizeof(game_object *)*tobjs,"Object list");
  55.   objs[tobjs-1]=o;
  56. }
  57.  
  58.  
  59. void simple_object::remove_light(light_source *ls)
  60. {
  61.   for (int i=0;i<tlights;i++) 
  62.   {
  63.     if (lights[i]==ls)
  64.     {
  65.       tlights--;
  66.       for (int j=i;j<tlights;j++)     // don't even think about it :)
  67.         lights[j]=lights[j+1];
  68.       lights=(light_source **)jrealloc(lights,sizeof(light_source *)*tlights,"object's lights");
  69.       return ;
  70.     }
  71.   }
  72. }
  73.  
  74. void simple_object::remove_object(game_object *o)
  75. {
  76.   for (int i=0;i<tobjs;i++) 
  77.   {
  78.     if (objs[i]==o)
  79.     {
  80.       tobjs--;
  81.       for (int j=i;j<tobjs;j++)     // don't even think about it :)
  82.         objs[j]=objs[j+1];
  83.       objs=(game_object **)jrealloc(objs,sizeof(game_object *)*tobjs,"object's lights");
  84.       return ;
  85.     }
  86.   }
  87. }
  88.  
  89.  
  90. simple_object::simple_object()
  91. {
  92.   
  93.   x=y=0;
  94.   direction=1;
  95.   otype=0;
  96.   state=stopped;
  97.   current_frame=0;
  98.  
  99.   Fade_dir=0;
  100.   Fade_count=0;
  101.   Fade_max=16;
  102.  
  103.  
  104.   tobjs=tlights=0;
  105.   objs=NULL;
  106.   lights=NULL;
  107.   Frame_dir=1;
  108.   mc=NULL;
  109.   Controller=NULL;
  110.  
  111.   Flags=0;
  112.   Xvel=Yvel=Xacel=Yacel=0;
  113.   Fx=Fy=Fxvel=Fyvel=Fxacel=Fyacel=Aitype=0;
  114.   Aistate=Aistate_time=0;
  115.   Hp=Mp=Fmp=0;
  116.   grav_on=1;
  117.   targetable_on=1;
  118. }
  119.  
  120.  
  121.  
  122. void simple_object::set_morph_status(morph_char *Mc)
  123. {
  124.   mc=Mc;
  125. }
  126.  
  127. void simple_object::clean_up()
  128. {
  129.   if (tlights) jfree(lights);
  130.   if (tobjs)   jfree(objs);
  131.   if (Controller)
  132.     Controller->focus=NULL;
  133. }
  134.  
  135.  
  136. simple_object default_simple;
  137.  
  138.  
  139.